import request from "@/utils/request";

enum ApiEnum {
  //用户登录
  userLogin = "/user/login",
  //获取二维码
  userQrCode = "/user/login/QCCode",
  //检查二维码扫描状态
  checkUserQrCode = "/user/getResponse/",
  //获取用户信息
  getUserInfo = "/customer/chat/getUser",
  //设置用户新信息
  setUserInfo = "/user/update",
  //修改密码
  changePassword = "/user/password/update",
}

/**
 * @description:用户登录
 */
export const userLoginApi = (data: any): Promise<any> => {
  return request({
    method: "post",
    url: ApiEnum.userLogin,
    data,
    formData: true,
  });
};

/**
 * @description: 获取二维码
 */
export const getUserQrCodeApi = (data?: any): Promise<any> => {
  return request({
    method: "post",
    url: ApiEnum.userQrCode,
    data,
    formData: true,
  });
};

/**
 * @description: 检查二维码扫描状态
 */
export const checkUserQrCodeApi = (key, params?: any): Promise<any> => {
  return request({
    method: "post",
    url: ApiEnum.checkUserQrCode + key,
    params,
    formData: true,
  });
};

/**
 * @description: 获取用户信息
 */
export const getUserInfoApi = (params: any): Promise<any> => {
  return request({
    method: "get",
    url: ApiEnum.getUserInfo,
    params,
  });
};

/**
 * @description: 设置用户信息
 */
export const setUserInfoApi = (data: any): Promise<any> => {
  return request({
    method: "post",
    url: ApiEnum.setUserInfo,
    data,
    formData: true,
  });
};

/**
 * @description: 修改密码
 */
export const changePasswordApi = (data: any): Promise<any> => {
  return request({
    method: "post",
    url: ApiEnum.changePassword,
    data,
    formData: true,
  });
};
